<link rel="stylesheet" href="<?=baseinfo?>/css/theme1/addcontent.css" type="text/css" media="all" />
<script src="<?=baseinfo?>/js/vendor/binaryajax.js"></script>
<script src="<?=baseinfo?>/js/vendor/exif.js"></script>
<script src="<?=baseinfo?>/js/vendor/canvasResize.js"></script>
<script src="<?=baseinfo?>/js/vendor/jquery.Jcrop.min.js"></script>
<script src="<?=baseinfo?>/js/vendor/jquery.iuploader-1.0.js"></script>


<script src="<?=baseinfo?>/js/coreadd.js"></script>


 <script>
 
 
 <?if($data['user']['roleid']!='2'&&$data['user']['roleid']!='3'&&$data['user']['roleid']!='4'){?>
 
  $('#postsignup').submit(function(){
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        if($('#postsignup input[name="fistnameuser"]').length)
        {
        
        if($('#postsignup input[name="fistnameuser"]').val()=='')
        {
            alertwrongboxmsgonly('Please Input Firstname');
            $('#postsignup input[name="fistnameuser"]').focus();
            return false;
        
        }else if($('#postsignup input[name="lastnameuser"]').val()=='')
        {
        
            alertwrongboxmsgonly('Please Input Lastname');
            $('#postsignup input[name="lastnameuser"]').focus();
            return false;
        
        
        
        }else if($('#postsignup input[name="emailnameuser"]').val()=='')
        {
        
            alertwrongboxmsgonly('Please Input Email');
            $('#postsignup input[name="emailnameuser"]').focus();
            return false;
        
        
        
        }else if(!re.test($('#postsignup input[name="emailnameuser"]').val()))
        {

            alertwrongboxmsgonly('Invalid your Email');
            $('#postsignup input[name="emailnameuser"]').focus();
            return false;

        }
        
        
        
        
        
        }
  
        if($('#postsignup input[name="serialuser"]').val()=='')
        {

            alertwrongboxmsgonly('Please Input Serail Number');
            $('#postsignup input[name="serialuser"]').focus();
            return false;

        }

    
        loaddata();
  $.post(serviceinfo+'saveuserdatacanon', $('#postsignup').serialize(), function(data) { 
        loadclosedata();
        if(data.error.response)
         {
          //alertbox(data.error.error);
          alertwrongboxmsgonly(data.error.error[0].msg);
         
         }else
         {
         if(data.data.userid)
         {
         
         $('#postsignup .registerCanonCampaign').remove();
         $('#postsignup input[name="serialuser"]').val('');
         alertrightboxmsgonly('Success');
         
         }
         
         
         }
  
  
  
  });
          return false;
  
  });
  
  <?}?>
  <?if(!$data['check']){?>
  <?if($data['user']['roleid']=='2'||$data['user']['roleid']=='3'||$data['user']['roleid']=='4'){?>
  var dataform={};
  var rowdiv=1;
  $( document ).ready(function() { 

    <?
$bookdata=0;
$uptime=0;
foreach($data['formadd'] as $keyform=> $valueform)
{
?>
dataform['<?=$keyform?>']='<?=$valueform;?>';
 
<?
if($keyform=='bookdata')
{
$bookdata=1;
}

if($keyform=='uptime')
{
$uptime=1;
}
 ?>



addform<?=$keyform?>();




<?
}
?>  
});



  function saveaddfeaturedatacanon()
  {
  var datasaveform={};
   var errorform={};
  var rowerror=0;
    
    
  if($('#uploadimagedata input[name="title"]').val()=='')
        {
            alertwrongboxmsgonly('กรุณาใส่ชื่อรูปภาพที่ส่งเข้าประกวด');
            $('#uploadimagedata input[name="title"]').focus();
            return false;
        
        }
   else    if($('#uploadimagedata input[name="imgmid[]"]').val()=='')
        {
            alertwrongboxmsgonly('กรุณาเลือกรูปภาพ');
           // $('#uploadimagedata input[name="title"]').focus();
            return false;
        
        }
   else    if($('#uploadimagedata textarea[name="text[]"]').val()=='')
        {
            alertwrongboxmsgonly('กรุณากรอกคำอธิบาย');
            $('#uploadimagedata textarea[name="text[]"]').focus();
            return false;
        
        }
        
      var arraydata={};  
      
      datasaveform['title']=$('#uploadimagedata input[name="title"]').val();
      datasaveform['imgmid']=183404;
      datasaveform['simgmid']=183404;
      datasaveform['contest']=$('#uploadimagedata input[name="contest"]:checked').val();
      datasaveform['plugin']={};
      var rowplugin=0;
      
      
      $.each($('div.featureclass'), function() {
        
        if(typeof($(this).find('input[name="plugname[]"]').val()) != "undefined")
        {
        
        eval("datasaveform['plugin'][rowplugin]=saveform"+$(this).find('input[name="plugname[]"]').val()+"('"+$(this).attr("id")+"','"+$(this).find('input[name="plugid[]"]').val()+"');");
        if(datasaveform['plugin'][rowplugin]['code']&&datasaveform['plugin'][rowplugin]['error'])
        {
        errorform[rowerror]=datasaveform['plugin'][rowplugin];
        rowerror++;
        }
        
        rowplugin++;
        
        }
    
    });
      
      
      console.log(datasaveform);
      
      if(rowerror>0)
    {
    //console.log(errorform);
    alertwrongbox(errorform);
    
    }else
    {
    loaddata();
     $.post(serviceinfo+'saveproductdatacanon', datasaveform, function(data) { 
     loadclosedata();
        if(data.error.response)
         {
          //alertbox(data.error.error);
          boxmsgdata(data.error.error);
         
         }else
         {
            location.href= baseinfo+'/'+data.data.link+'/'+data.data.productid
         }
     
     
     });
    
    
    
    }
        
             
   
  return false;
  
  }
  
  $('#btnsubmit').click(function() {

//$('#formaddfeature').submit();
saveaddfeaturedatacanon();

});
  
  
  <?}
  }
  ?>
  
 </script>